$(function(){
	$("[data-toggle='popover']").popover();
	
	$(document).on('click','.add-btn',function(){
		var addOrgId=$("#addOrgId").val();
		var addOrgName=$("#addOrgName").val();
		var selectParentOrg=$("#selectParentOrg").data("orgid");
		var addAddress=$("#addAddress").val();
		var isAdminInstName=$('input[name="isAdminInstName"]:checked').val();
		var isShowName=$('input[name="isShowName"]:checked').val();
		
		console.log("selectParentOrg="+selectParentOrg);
		if(isNull(addOrgName)){
			layer.msg("组织名称不能为空！");
			return;
		}
		if(isNull(selectParentOrg)){
			layer.msg("请选择上级组织机构 ！");
			return;
		}
		
		
		$.ajax({
			type:"post",
			url:basePath+"/org/cuOrg",
			dataType:"json",	
			async: false,
			data:{"orgId":addOrgId,"orgName":addOrgName,"parentOrgId":selectParentOrg,"orgAddress":addAddress,"isAdminInstitute":isAdminInstName,"isShow":isShowName},
			success:function(data){
				if(addOrgId==null||addOrgId==""){
					if(data.code==200){
						retSuccPop('添加成功'); 
					}else if(data.code==201){
						retFailPop('添加失败','此组织有下级组织，不能删除该数据');
					}
				}else{
					if(data.code==200){
						retSuccPop('修改成功'); 
					}else{
						retFailPop('修改失败',data.msg);
					}
				}	
			}
		})
		
	})
})
